' Requires XUI, JavaObject and BitmapCreator (jBitmapCreator on B4J).
' Add the declarations to Class_Globals or Process_Globals.
Private MeshGradient As UIGradientMarket
Private MeshTarget As B4XView
Private MeshColors As List

' Call SetupMeshBackground(YourPanel) after the target has a positive size.
' In the form/page resize event, call RefreshMeshBackground AFTER resizing the panel.
Private Sub SetupMeshBackground(Target As B4XView)
    MeshGradient.Initialize
    MeshTarget = Target
    MeshColors = Array As Int(0xFFFF6489, 0xFF8262EC, 0xFF28C9BC, 0xFFFFB86C)
    RefreshMeshBackground
End Sub

Private Sub RefreshMeshBackground
    If MeshTarget.IsInitialized = False Then Return
    MeshGradient.SetAutoGradientWithCorners(MeshTarget, MeshColors, 12dip, 320)
End Sub

' Replace MeshColors with any caller-defined ARGB palette (1..32 colors).
' For a simple background without rounded corners: MeshGradient.SetAutoGradient(MeshTarget, MeshColors)
' Call MeshGradient.ClearMeshCache to release the last cached bitmap.
